/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.ucitech.filedb.example;

import com.ucitech.filedb.PersistentMap;
import java.io.IOException;
import java.util.Collection;
import java.util.Set;

/**
 *
 * @author Charlee
 */
public class Example extends PersistentMap<ExampleRecord>{
    private static Example instance;

    private Example() throws IOException {
        super("/var/lib/sample.cache", 100); // file,max datasize per entry (bytes)
    }
    
    synchronized static Example getInstance() {
        if (instance==null) {
            try {
                instance = new Example();
                instance.putData(new ExampleRecord("John Smith", "3 Park Lane", "014251111"));
            } catch (IOException ex) {
                throw new RuntimeException(ex);
            }
        }
        return instance;
    }

    @Override
    public ExampleRecord load(String csvdata) {
        return new ExampleRecord(csvdata);
    }
    
    public ExampleRecord getData(String key){
        return get(key);
    }
    
    public void putData(ExampleRecord data){
        this.insert(data);
    }
    
    @Override
    public Collection<ExampleRecord> values(){
        return super.values();
    }
    
    @Override
    public boolean containsKey(String key){
        return super.containsKey(key);
    }
    
    @Override
    public Set<String> keySet(){
        return super.keySet();
    }
    
    @Override
    public void remove(String key){
        super.remove(key);
    }
    
    @Override
    public int size(){
        return super.size();
    }
}
